<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>商品管理页面</h1>
<table border="1">
    <tr>
        <th align="center">编号</th>
        <th align="center">商品标题</th>
        <th align="center">商品价格</th>
        <th align="center">商品库存</th>
        <th align="center" colspan="2">操作</th>
    </tr>
    <tr v-for="p in arr">
        <td align="center">{{p.id}}</td>
        <td align="center">{{p.title}}</td>
        <td align="center">{{p.price}}</td>
        <td align="center">{{p.saleCount}}</td>
        <td align="center"><a href="javascript:void(0)" @click="del(p.id)">删除</a></td>
        <td align="center"><a :href="'/update.html?id='+p.id">修改</a></td>
    </tr>
</table>
<script src="js/vue.js"></script>
<script src="js/axios.min.js"></script>
<script>
    let v = new Vue({
        el:"table",
        data:{
            arr:[]
        },
        created(){
            axios.get("/select").then(function (response){
                v.arr= response.data;
            })
        },
        methods:{
            del(id){
                axios.get("/delete?id="+id).then(function (response){
                    alert("删除完成!")
                    location.reload();
                })
            }
        }
    })
</script>

</body>
</html>